<template>
  <section class="container">
    <div>
      <h1 class="title">
        {{username}}
      </h1>
      <div class="links">
        <div @click="logout" class="button--green">退出</div>
      </div>
    </div>
  </section>
</template>

<script>
  import axios from 'axios'

  export default {
    middleware: 'auth',
    data () {
      return {
        username: ""
        }
    },
    asyncData ({store,route}) {      
      return { 
        username : store.state.userInfo?store.state.userInfo.username:""
      }
    },
    fetch(context){
        
    },
    created(){
      
    },
    methods:{
      async getUserInfo(){
        
      },
      async logout(){
        let {data} = await axios.get('/proxy/auth/logout')
        if(data.status==1){
          this.$store.dispatch('logout')
          this.$router.push({path:'/'})
        }
      }
    },
    updated(){
        
    }

  }
</script>